package com.UnionPayCenter.account.enums;

import com.UnionPayCenter.enums.CodeBaseEnum;
import com.UnionPayCenter.exception.ApiException;

public enum ChargeTypeEnum implements CodeBaseEnum {

    // 充值类型,1汇款、2网银、3账户验证
    TO_RECHARGE(1, "汇款"),
    RECHARGEING(2, "网银"),
    SUCCESS(3, "账户验证");

    private int code;

    private String msg;

    ChargeTypeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ChargeTypeEnum getEnum(int code) {
        for (ChargeTypeEnum ele : ChargeTypeEnum.values()) {
            if (ele.code == code) {
                return ele;
            }
        }
        throw new ApiException(404, "不正确的充值类型码");
    }

    @Override
    public int code() {
        return this.code;
    }

    @Override
    public String msg() {
        return msg;
    }
}
